<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

    <!-- 引入JSON数据展示样式 -->
    <link href="./js_example/script/script/utils/json/search.css" rel="stylesheet">
    <link href="./js_example/script/script/utils/json/prety-json.css" rel="stylesheet">
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>
    <div class="card-panel card-panel-top-right">
        <div class="card-json-info">
            <div class="input-item">
                <div class="input-item-prepend">
                    <span class="input-item-text" style="width:50px;">属性</span>
                </div>
                <input id='attr-input' type="text" autocomplete="off" style="width: 150px;" value="objectid = 126">
                <button onclick="querySearchResult()" class="demo-btn"
                    style="height: 30px;border-bottom-left-radius: 0;border-top-left-radius: 0;">geo查询
                </button>
                <button onclick="querySearchResult1()" class="demo-btn"
                    style="height: 30px;border-bottom-left-radius: 0;border-top-left-radius: 0;">arc查询
                </button>
            </div>
            <div class="info"><span id="result-info"></span></div>
        </div>
    </div>
    <div id="mapui"></div>
    <div id="search_key_tem" style="display:none;width: 220px;height:100px;word-break: normal ">
        <b>行政名称:</b>~[xzmc]<br />
        <b>行政编码:</b>~[xzbm]<br />
    </div>
    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>

    <script>
        

        var amap = null;
        let geoSearchService = null;
        let arcSearchService = null;
        map.Factory.create('mapui', {
            style: style,
            center: center,
            zoom: 11,
            strategy: ['mapboxgl', 'openlayers', 'leaflet'],
            fullExtent: {
                xmin: 108.23365,
                ymin: 17.95253,
                xmax: 111.78395,
                ymax: 20.13104
            }
        }, (o) => {
            amap = o;


        });

        function querySearchResult() {
            var where = document.getElementById("attr-input").value;

            if (geoSearchService) {
                geoSearchService.clear();
            }

            map.Factory.SimpleSearch('AttributeSearch', function (attributeSearch) {
                geoSearchService = attributeSearch;
                attributeSearch.init('geoserver', {
                    infoTemplateId: "search_key_tem",//弹窗模板ID
                });
                attributeSearch.search({
                    baseUrl: 'http://129.211.11.95:8066/geoserver/itfeer/wfs',
                    layerName: 'jtjs_jc_xiang_pt',
                    // where: "objectid between 126 and 136",
                    where: where,

                }, (e) => {
                    //对查询的数据定位，并且在地图上展示
                    attributeSearch.localByBounds();
                    attributeSearch.showFeatures();
                })
            })

        }

        function querySearchResult1() {
            if (arcSearchService) {
                arcSearchService.clear();
            }

            var where = document.getElementById("attr-input").value;

            map.Factory.SimpleSearch('AttributeSearch', function (attributeSearch) {
                arcSearchService = attributeSearch;
                attributeSearch.init('arcgis', {
                    infoTemplateId: "search_key_tem",//弹窗模板ID
                });
                attributeSearch.search({
                    baseUrl: '	http://localhost:6080/arcgis/rest/services/jtjs_jc_xiang_pt/MapServer',
                    layerName: '0',
                    // where: "objectid between 126 and 136",
                    where: where,

                }, (e) => {
                    //对查询的数据定位，并且在地图上展示
                    attributeSearch.localByBounds();
                    attributeSearch.showFeatures();
                })
            })

        }

    </script>
</body>

</html>